package com.sunjob.mroresumeproject.dao;

import com.sunjob.common.domain.mroresume.TFBus;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface TFBusMapper {


    @Select("select count(*) from tf_busresume where status=1 and types=#{types}")
    int querycount(String types);

    @Select("select transformid,bustypes,fault,management,TFstate from tf_busresume where status=1 and types=#{types} limit #{i},#{size}")
    List<TFBus> querytransform(int i, int size,String types);

    @Select("select transformid,bustypes,fault,management,TFstate from tf_busresume where transformid=#{transformid}  and status=1")
    @Results({
            @Result(property = "transformid",column = "transformid"),
            @Result(property = "fault",column = "fault"),
            @Result(property = "bustypes",column = "bustypes"),
            @Result(property = "management",column = "management"),
            @Result(property = "TFstate",column = "TFstate"),
    })
    List<TFBus> querytransform2(Long transformid);



  @Insert("insert into tf_busresume values(#{transformid},#{types},#{bustypes},#{useparts},#{management},#{fault},#{TFstate},#{money},#{failreason},#{starttime},#{endtime},#{status})")
  void inserttransform(TFBus tfBus);



    @Select("select transformid, types,bustypes,Use_parts,management,fault,TFstate,failreason,money,starttime,endtime from tf_busresume where status=1 and transformid=#{transformid}")
    @Results({
            @Result(property = "transformid",column = "transformid"),
            @Result(property = "types",column = "types"),
            @Result(property = "bustypes",column = "bustypes"),
            @Result(property = "useparts",column = "Use_parts"),
            @Result(property = "management",column = "management"),
            @Result(property = "fault",column = "fault"),
            @Result(property = "TFstate",column = "TFstate"),
            @Result(property = "failreason",column = "failreason"),
            @Result(property = "money",column = "money"),
            @Result(property = "starttime",column = "starttime"),
            @Result(property = "endtime",column = "endtime")

    })
    List<TFBus> querytransformone(String transformid);







    @Update("update tf_busresume set types=#{types},bustypes=#{bustypes},Use_parts=#{useparts},management=#{management},fault=#{fault},TFstate=#{TFstate},failreason=#{failreason},money=#{money},starttime=#{starttime},endtime=#{endtime} where transformid=#{transformid}")
//    void updatetransform(long transformid, String types, String bustypes, String useparts, String management, String fault, String tFstate, String failreason, Double money);
    void updatetransform(TFBus tfBus);

    @Update("update tf_busresume set status = 0 where transformid = #{transformid}")
    void deletetransform(String transformid);






    @Update("update tf_busresume set status = 0 where transformid = #{s}")
    void deletetransformone(String s);

    @Select("select transformid, types,bustypes,Use_parts,management,fault,TFstate,failreason,money,starttime,endtime from tf_busresume where status=1 and transformid=#{transformid}")
    @Results({
            @Result(property = "transformid",column = "transformid"),
            @Result(property = "types",column = "types"),
            @Result(property = "bustypes",column = "bustypes"),
            @Result(property = "useparts",column = "Use_parts"),
            @Result(property = "management",column = "management"),
            @Result(property = "fault",column = "fault"),
            @Result(property = "TFstate",column = "TFstate"),
            @Result(property = "failreason",column = "failreason"),
            @Result(property = "money",column = "money"),
            @Result(property = "starttime",column = "starttime"),
            @Result(property = "endtime",column = "endtime")

    })
    TFBus query2(String transformid);
}
